<template>
  <div>
    <el-tabs
      class="main" v-model="activeName">
      <el-tab-pane label="我的申请" name="MyLeaveApply">
        <my-leave-apply/>
      </el-tab-pane>
      <el-tab-pane label="申请审批" name="ApplyCheck" v-if="role === 1">
        <!-- 由部门主管、部门经理审批 -->
        <to-leave-apply/>
      </el-tab-pane>

    </el-tabs>
  </div>
</template>

<script>
import ToLeaveApply from "./components/ToLeaveApply";
import MyLeaveApply from "./components/MyLeaveApply";
export default {
  name: "ProLeave",
  components: {MyLeaveApply, ToLeaveApply},
  data(){
    return {
      activeName:'MyLeaveApply',
      userInfo: JSON.parse(sessionStorage.getItem('userInfo')),
      role:0,
    }
  },
  methods: {
    checkRoles(roles) {
      roles.map(item => {
        if (item.id == 3 || item.id == 4) {
          this.role = 1;
          return;
        }
      })
    }
  },
  mounted() {
    // 检查权限
    this.checkRoles(this.userInfo.roles);
  }
}
</script>

<style>

</style>
